package com.yeswater.canal.utils;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @Description:
 * @author： yeswater
 * @create： 2024/6/25
 */

public class RedisUtils {
	public static final String REDIS_IP_ADDR = "192.168.56.11";
	public static final String REDIS_PWD = "111111";
	public static JedisPool jedisPool;
	
	static {
		JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
		jedisPoolConfig.setMaxTotal(20);
		jedisPoolConfig.setMaxIdle(10);
		jedisPool = new JedisPool(jedisPoolConfig, REDIS_IP_ADDR, 6379, 10000, REDIS_PWD);
	}
	
	public static Jedis getJedis() throws Exception {
		if (null != jedisPool) {
			return jedisPool.getResource();
		}
		throw new Exception("Jedis pool is not ok");
	}
	
}
